<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<!-- 网页使用的语言 -->
<html lang="zh-CN">
<head>
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的浏览器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport视口：网页可以根据设置的宽度自动进行适配，在浏览器的内部虚拟一个容器，容器的宽度与设备的宽度相同。
    width: 默认宽度与设备的宽度相同
    initial-scale: 初始的缩放比，为1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>管理员管理</title>

    <!-- 1. 导入CSS的全局样式 -->
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="../js/jquery-2.2.3.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="../js/bootstrap.min.js"></script>
    <script>
        function openwindow(){
            window.open ("${pageContext.request.contextPath}/jsp/NewBox.jsp","Sample","fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, copyhistory=no,width=600,height=400,left=350,top=100");
        }
        /*在NewBox.jsp里调用这个函数，用来刷新AddName.jsp*/
        function opensub(){
            location.href="${pageContext.request.contextPath}/admin/findAll";
        }
        function delAdmin(aid) {
            if (confirm("确定是否要删除?")) {
                <%--location.href=${pageContext.request.contextPath}+"/delUserServlet";--%>
                location.href = "${pageContext.request.contextPath}/admin/delAdminById?aid=" + aid;
            }
        }

    </script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
</head>
<body>
<div class="container">
    <div style="width: 100%; height: 60px; background-color: #0078D7">
        <img style="float: left; margin: 8px; margin-right: 20px;" src="../images/logo.jpg">
        <div style="float: right; margin: 12px; margin-right: 20px; background-color: #5cb85c">
            <a class="btn" href="addadmin.jsp"><font color="white">返回</font></a>
        </div>
        <div style="float: right; margin: 12px; margin-right: 5px; background-color: #5cb85c">
            <a class="btn" href="javascript:openwindow()"><font color="white">新增</font></a>
        </div>
    </div>

    <form action="${pageContext.request.contextPath}/delCheckedUsersServlet" id="usersForm" method="post">
        <table border="1" class="table table-bordered table-hover">
            <tr class="success">
                <th>姓名</th>
                <th>用户名</th>
                <th>密码</th>
                <th>操作</th>
            </tr>

            <c:forEach items="${pb.list}" var="admin" varStatus="s">
                <tr>
<%--                    设置一个隐藏域--%>
                    <input type="hidden" name="adminid" value="${admin.aid}">
                    <td>${admin.aname}</td>
                    <td>${admin.username}</td>
                    <td>${admin.password}</td>
                    <td><a class="btn btn-default btn-sm"
                           href="${pageContext.request.contextPath}/admin/findUserById?aid=${admin.aid}">修改</a>&nbsp;
                        <a class="btn btn-default btn-sm" href="javascript:delAdmin(${admin.aid});">删除</a></td>
                </tr>

            </c:forEach>


        </table>
    </form>
    <%--此处为分页栏--%>
    <div>
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <c:if test="${pb.currentPage<=1}">
                    <li class="disabled" }>
                        <a href="javascript:void(0);" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>
                <c:if test="${pb.currentPage>1}">
                    <li class="" }>
                        <a href="${pageContext.request.contextPath}/admin/findAll?currentPage=${pb.currentPage-1}"
                           aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>
                <c:forEach begin="1" step="1" var="thisPage" end="${pb.totalPage}">
                    <c:if test="${thisPage!=pb.currentPage}">
                        <li class="" }>
                            <a href="${pageContext.request.contextPath}/admin/findAll?currentPage=${thisPage}">${thisPage}</a>
                        </li>
                    </c:if>
                    <c:if test="${thisPage==pb.currentPage}">
                        <li class="active" }><a href="javascript:void(0);">${thisPage}</a></li>
                    </c:if>
                </c:forEach>
                <c:if test="${pb.currentPage<pb.totalPage}">
                    <li class="" }>
                        <a href="${pageContext.request.contextPath}/admin/findAll?currentPage=${pb.currentPage+1}"
                           aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>
                <c:if test="${pb.currentPage>=pb.totalPage}">
                    <li class="disabled" }>
                        <a href="javascript:void(0);" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>

                <span style="font-size: 25px;margin-left: 5px;">
                    共${pb.totalCount}条记录，共${pb.totalPage}页
                </span>

            </ul>
        </nav>


    </div>
</div>
</body>
</html>
